package domfarr.json;

import java.util.Arrays;

import net.sf.json.JSONObject;

import org.apache.tapestry5.OptionModel;
import org.apache.tapestry5.internal.OptionGroupModelImpl;
import org.apache.tapestry5.internal.OptionModelImpl;

public class ObjectToJSon {
	
	public static void main(String[] args) {
		OptionModelImpl option1 = new OptionModelImpl("optionLabel 1", "optionValue 1");
		OptionModelImpl option2 = new OptionModelImpl("optionLabel 2", "optionValue 2");
		
		OptionModel[] options = new OptionModelImpl[] {option1, option2};
		
		OptionGroupModelImpl product = new OptionGroupModelImpl("Group Label", false, Arrays.asList(options));
		
		JSONObject jsonObject = JSONObject.fromObject(product);
		
		System.out.println(jsonObject.toString());
	}
}
